package com.red.star.macalline.data.utils;

import com.alibaba.fastjson.JSONObject;
import com.red.star.macalline.data.entity.SysParam;
import org.apache.http.client.fluent.Request;

import java.io.IOException;

public class FileUtil {

    /**
     * 获取文件上传token
     *
     * @param empNo
     * @return
     */
    public static String fetchToken(String empNo) {
        String url = SysParam.MACALLIEN_FILE_TOKEN_URL + empNo;
        Request request = Request.Get(url);
        String resp = HttpUtil.fetch(request);
        JSONObject object = JSONObject.parseObject(resp);
        if(object!=null && object.get("code")!= null && (Integer)object.get("code")==200) {
            return object.get("message").toString();
        }
        return null;
    }

    public static void main(String args[]){
        System.out.println(fetchToken("51045443"));
    }
}
